package com.sitech.portal.util;

import com.sitech.ibnms.util.DateFormater;
import com.sitech.ismp.workflow.util.DES3;

public class UrlSSOUtil {

    public static String encryptUrl(String url, String userId) {
        if (url == null || url.equals(""))
            return null;

        try {
            if (url.indexOf("?") > 0)
                url += "&";
            else
                url += "?";

            String timestamp = DateFormater.getFormatTime("yyyyMMddHHmmssSSS");
            String secret = DES3.encrypt(userId + "#" + timestamp);

            url += "loginName=" + userId + "&timestamp=" + timestamp + "&secret=" + secret;
        } catch (Exception e) {
            e.printStackTrace();
        }

        return url;
    }
}
